package com.huawang.mdesign.model.service.controller;

import com.huawang.mdesign.model.service.inter.simulationintegration.SimulationIntegrationService;
import com.huawang.mdesign.model.service.dto.SimulationContextDTO;
import com.huawang.mdesign.model.service.vo.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Tag(name = "仿真集成")
@RestController
@RequestMapping("/simulation/integration")
@Validated
@Slf4j
public class SimulationIntegrationController {

    @Autowired
    private SimulationIntegrationService simulationIntegrationService;

    @Operation(summary = "开始仿真")
    @PostMapping("/star")
    public BaseResponse<Boolean> start(@RequestBody Map<String, Object> params) {
        return BaseResponse.success(simulationIntegrationService.start(params));
    }

    @Operation(summary = "暂停仿真")
    @PostMapping("/pause")
    public BaseResponse<Boolean> pause(@RequestBody Map<String, Object> params) {
        return BaseResponse.success(simulationIntegrationService.pause(params));
    }

    @Operation(summary = "停止仿真")
    @PostMapping("/stop")
    public BaseResponse<Boolean> stop(@RequestBody Map<String, Object> params) {
        return BaseResponse.success(simulationIntegrationService.stop(params));
    }

    @Operation(summary = "获取执行过的节点")
    @PostMapping("/executed/nodes")
    public BaseResponse<SimulationContextDTO> getExecutedNodes(@RequestBody SimulationContextDTO dto) {
        return BaseResponse.success(simulationIntegrationService.getExecutedNodes(dto));
    }
}
